package timing.ukulele.auth.security;

import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.Optional;

public enum ThirdTypeEnum {
    WECHAT_WEB(0, "微信网页"),
    WECHAT_APP(1, "微信小程序"),
    WECHAT_MP(2, "微信公众号");
    private Integer code;
    private String name;

    ThirdTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static ThirdTypeEnum getByCode(Integer code) {
        if (code == null)
            return null;
        Optional<ThirdTypeEnum> first = Arrays.stream(values()).filter(item -> item.getCode().equals(code)).findFirst();
        return first.orElse(null);
    }
}
